<script setup>
import {ref} from "vue";

let viewTableTreeData = ref([
  {
    ukId: "系统管理",
    name: "系统管理",
    type: "catalog",
    path: "/manage",
    icon: "x",
    status: "enable",
    sort: 0,
    children: [
      {
        ukId: "账户管理",
        name: "账户管理",
        type: "catalog",
        path: "/manage/account",
        icon: "x",
        status: "enable",
        sort: 0,
        children: [
          {
            ukId: "新建账户",
            name: "新建账户",
            type: "menu",
            path: "",
            icon: "x",
            status: "enable",
            sort: 0,
            children: [

            ]
          },
          {
            ukId: "删除账户",
            name: "删除账户",
            status: "enable",
            sort: 0,
            children: [

            ]
          },
        ]
      },
      {
        ukId: "角色管理",
        name: "角色管理",
        status: "enable",
        sort: 0,
        children: [
          {
            ukId: "创建角色",
            name: "创建角色",
            status: "enable",
            sort: 0,
            children: [

            ]
          },
          {
            ukId: "删除角色",
            name: "删除角色",
            status: "enable",
            sort: 0,
            children: [

            ]
          },
        ]
      },
    ]
  },
  {
    ukId: "外部链接",
    name: "外部链接",
    type: "link",
    path: "https://www.baidu.com",
    icon: "x",
    status: "enable",
    sort: 0,
  }
])
</script>

<template>
  <div style="display: flex; flex-flow: column nowrap; width: 100%; height: 100%; overflow: hidden;">
    <div style="display: flex; flex-flow: row nowrap; align-items: center; height: 40px;">
      <el-form :inline="true" style="height: 30px">
        <el-form-item label="Name">
          <el-input clearable/>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleDictList">Search</el-button>
          <el-button type="primary" @click="handleDictCreate({})">New</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-table
        :data="viewTableTreeData"
        style="width: 100%;"
        row-key="ukId"
        border
        default-expand-all
    >
      <el-table-column prop="name" label="Name" />
      <el-table-column prop="type" label="Type" width="90" />
      <el-table-column prop="path" label="Path" width="370" />
      <el-table-column prop="icon" label="Icon" width="70" />
      <el-table-column prop="status" label="Status" width="70">
        <template #default="scope">
          <el-switch
              active-value="enable"
              inactive-value="disable"
              v-model="scope.row.status "
          />
        </template>
      </el-table-column>
      <el-table-column prop="sort" label="sort" width="60"/>
      <el-table-column label="operations" width="180">
        <template #default="scope">
          <el-button @click="handleEdit(scope.$index, scope.row)">
            编辑
          </el-button>
          <el-popconfirm
              width="170"
              hide-icon
              confirm-button-text="确定"
              cancel-button-text="取消"
              @confirm="handleDictDelete(scope.row)"
              :title="'是否确认删除视图数据 [ ' + scope.row.name + ' ] ？'">
            <template #reference>
              <el-button type="danger">
                删除
              </el-button>
            </template>
          </el-popconfirm>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<style scoped>

</style>